package leetcode_周赛._2021._202108._20210822;

import java.util.Arrays;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/8/22 10:30
 */
public class _5850 {

    public int findGCD(int[] nums) {
        Arrays.sort(nums);
        return getNumber(nums[0], nums[nums.length - 1]);
    }

    private static int getNumber(int x, int y) {
        int big = x > y ? x : y;
        int small = x < y ? x : y;
        if (big % small == 0) {
            return small;
        }
        return getNumber(big % small, small);
    }

}
